package com.gaohe.web.controller.hotal;

import java.util.List;

import com.gaohe.hotal.domain.HotBrand;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.hotal.service.IHotBrandService;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.common.core.page.TableDataInfo;

/**
 * 品牌管理Controller
 *
 * @author zl
 * @date 2025-06-26
 */
@RestController
@RequestMapping("/hotal/brand")
public class HotBrandController extends BaseController
{
  @Autowired
  private IHotBrandService hotBrandService;
  /**
   * 查询品牌管理列表
   */
  @PreAuthorize("@ss.hasPermi('hotal:brand:list')")
  @GetMapping("/list")
  public TableDataInfo list(HotBrand hotBrand)
  {
    startPage();
    List<HotBrand> list = hotBrandService.selectHotBrandList(hotBrand);
    return getDataTable(list);
  }

  /**
   * 导出品牌管理列表
   */
  @PreAuthorize("@ss.hasPermi('hotal:brand:export')")
  @Log(title = "品牌管理", businessType = BusinessType.EXPORT)
  @PostMapping("/export")
  public void export(HttpServletResponse response, HotBrand hotBrand)
  {
    List<HotBrand> list = hotBrandService.selectHotBrandList(hotBrand);
    ExcelUtil<HotBrand> util = new ExcelUtil<HotBrand>(HotBrand.class);
    util.exportExcel(response, list, "品牌管理数据");
  }

  /**
   * 获取品牌管理详细信息
   */
  @PreAuthorize("@ss.hasPermi('hotal:brand:query')")
  @GetMapping(value = "/{brandId}")
  public AjaxResult getInfo(@PathVariable("brandId") Long brandId)
  {
    return success(hotBrandService.selectHotBrandByBrandId(brandId));
  }

  /**
   * 新增品牌管理
   */
  @PreAuthorize("@ss.hasPermi('hotal:brand:add')")
  @Log(title = "品牌管理", businessType = BusinessType.INSERT)
  @PostMapping
  public AjaxResult add(@RequestBody HotBrand hotBrand)
  {
    return toAjax(hotBrandService.insertHotBrand(hotBrand));
  }

  /**
   * 修改品牌管理
   */
  @PreAuthorize("@ss.hasPermi('hotal:brand:edit')")
  @Log(title = "品牌管理", businessType = BusinessType.UPDATE)
  @PutMapping
  public AjaxResult edit(@RequestBody HotBrand hotBrand)
  {
    return toAjax(hotBrandService.updateHotBrand(hotBrand));
  }

  /**
   * 删除品牌管理
   */
  @PreAuthorize("@ss.hasPermi('hotal:brand:remove')")
  @Log(title = "品牌管理", businessType = BusinessType.DELETE)
  @DeleteMapping("/{brandIds}")
  public AjaxResult remove(@PathVariable Long[] brandIds)
  {
    return toAjax(hotBrandService.deleteHotBrandByBrandIds(brandIds));
  }
  //-------------------------------
  /**
   * 品牌查询
   */
  @PreAuthorize("@ss.hasPermi('hotal:brand:list')")
  @GetMapping("/listBrand")
  public TableDataInfo listBrand(HotBrand hotBrand)
  {
    startPage();
    List<HotBrand> list = hotBrandService.selectHotBrandList(hotBrand);
    return getDataTable(list);
  }

  /**
   * 通过id查询品牌
   */
  @PreAuthorize("@ss.hasPermi('hotal:brand:query')")
  @GetMapping(value = "/getBrandById/{brandId}")
  public AjaxResult getBrandById(@PathVariable("brandId") Long brandId)
  {
    return success(hotBrandService.selectHotBrandByBrandId(brandId));
  }

  /**
   * 新增品牌
   */
  @PreAuthorize("@ss.hasPermi('hotal:brand:add')")
  @Log(title = "品牌管理", businessType = BusinessType.INSERT)
  @PostMapping("/addBrand")
  public AjaxResult addBrand(@RequestBody HotBrand hotBrand)
  {
    return toAjax(hotBrandService.insertHotBrand(hotBrand));
  }

  /**
   * 修改品牌
   */
  @PreAuthorize("@ss.hasPermi('hotal:brand:edit')")
  @Log(title = "品牌管理", businessType = BusinessType.UPDATE)
  @PutMapping("/updateBrand")
  public AjaxResult updateBrand(@RequestBody HotBrand hotBrand)
  {
    return toAjax(hotBrandService.updateHotBrand(hotBrand));
  }

  /**
   * 删除品牌
   */
  @PreAuthorize("@ss.hasPermi('hotal:brand:remove')")
  @Log(title = "品牌管理", businessType = BusinessType.DELETE)
  @DeleteMapping("/deleteBrand/{brandIds}")
  public AjaxResult deleteBrand(@PathVariable Long[] brandIds)
  {
    return toAjax(hotBrandService.deleteHotBrandByBrandIds(brandIds));
  }
}
